package myalg.singleton;

/**
 * @author Pavel Belevich
 *         Date: Jun 29, 2012
 *         Time: 2:18:24 PM
 */
public class VolatileCacheDCLFactory {

    private volatile Singleton instance;

    public Singleton getInstance() {
        Singleton res = instance;
        if (res == null) {
            synchronized (this) {
                if (instance == null) {
                    instance = new DefaultSingleton();
                }
            }
            return instance;
        }
        return res;
    }

}
